using System.Reflection;
using System.Configuration;

namespace Webcar.BLL
{
    public sealed class DataAccess
    {
        private static readonly string path = ConfigurationManager.AppSettings["DAL"];
        private static readonly string dllpath = ConfigurationManager.AppSettings["DALAssembly"];

        private DataAccess() { }

        public static Webcar.Interface.ICar CreateCar()
        {
            string className = path + ".Car";
            return (Webcar.Interface.ICar)Assembly.Load(dllpath).CreateInstance(className);
        }
        public static Webcar.Interface.IDriver CreateDriver()
        {
            string className = path + ".Driver";
            return (Webcar.Interface.IDriver)Assembly.Load(dllpath).CreateInstance(className);
        }

        public static Webcar.Interface.IUser CreateUser()
        {
            string className = path + ".User";
            return (Webcar.Interface.IUser)Assembly.Load(dllpath).CreateInstance(className);
        }
        public static Webcar.Interface.ISearch CreateSearchBLL()
        {
            string className = path + ".Search";
            return (Webcar.Interface.ISearch)Assembly.Load(dllpath).CreateInstance(className);
        }

        public static Webcar.Interface.ISearialNo CreateSearialNo()
        {
            string className = path + ".SearialNoGenerator";
            return (Webcar.Interface.ISearialNo)Assembly.Load(dllpath).CreateInstance(className);
        }
        public static Webcar.Interface.IPurview CreatePurview()
        {
            string className = path + ".Purview";
            return (Webcar.Interface.IPurview)Assembly.Load(dllpath).CreateInstance(className);
        }
    }
}
